//
//  MainPageViewController.m
//  MoreFun
//
//  Created by Pro on 2018/4/30.
//  Copyright © 2018年 Pro. All rights reserved.
//

#import "MainPageViewController.h"


@interface MainPageViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)NSMutableArray * titleArray;
@property (weak, nonatomic) IBOutlet UITableView *MainTableView;
@end

@implementation MainPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"首页";
    self.MainTableView.delegate = self;
    self.MainTableView.dataSource = self;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [[UITableViewCell alloc]init];
    cell.textLabel.text = self.titleArray[indexPath.row];
    cell.textLabel.textAlignment = NSTextAlignmentCenter;
    return cell;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.titleArray.count;
}

-(NSMutableArray *)titleArray{
    if(_titleArray == nil){
        _titleArray = [NSMutableArray arrayWithObjects:@"网络请求",@"图片上传",@"js交互",@"redis数据", nil];
    }
    return _titleArray;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0){
        NetWorkViewCtl * vc = [[NetWorkViewCtl alloc]init];
        [self.navigationController pushViewController: vc animated:YES];
    }else if (indexPath.row == 1){
        ImageUpLoadViewCtl * vc = [[ImageUpLoadViewCtl alloc]init];
        [self.navigationController pushViewController: vc animated:YES];
    }else if (indexPath.row == 2){
        JSPageViewCtl * vc = [[JSPageViewCtl alloc]init];
        [self.navigationController pushViewController: vc animated:YES];
    }else if (indexPath.row == 3){
        RedisViewCtl * vc = [[RedisViewCtl alloc]init];
        [self.navigationController pushViewController: vc animated:YES];
    }
    
}

@end
